#!/bin/bash

. $(dirname $0)/aux-funcs

# 定义记录文件
LOG_FILE="./log/gateway_ping.log"

while true; do

# Ping网关
if ping -c 1 -s 2000 -I eth0 $(get_gateway) 2>&1; then
    echo "$(date) - Gateway is reachable." >> $LOG_FILE
else
    echo "$(date) - Gateway is unreachable." >> $LOG_FILE
    let ping_count++
    echo "$(date) - Ping failures: $ping_count" >> $LOG_FILE
fi

# 等待一段时间再进行下一次循环，例如5秒
sleep 2

done
